import Axios from 'axios'

const env = process.env.NODE_ENV;
const dev = "development";

const service = Axios.create({
    baseURL: env===dev?'/':'/',
    headers: {
        'Accept': '*/*'
    },
    timeout: 3000
})
service.defaults.withCredentials=true

service.interceptors.request.use(
    config => {
        return config
    },
    error => {
        Promise.reject(error)
    }
)

service.interceptors.response.use(
    response => {//Grade
        const {data} = response;
        if(data.code !== 0) {
            alert("请求出错")
        }
        return data;
    },
    error => {
        return Promise.reject(error)
    }
)

export default service